home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_nn-tk.idb / usr / freeware / lib / nn / tcl / windows.tcl.z / windows.tcl
Encoding:
Text File  |  1999-04-16  |  33.2 KB  |  1,394 lines

  1. #
  2. #  Popup showing nntp transfer  progress
  3. #
  4. proc nntp_lmsg {cnt aflg} {
  5.     global Config
  6.  
  7.     mprompt_msg $cnt
  8.     update
  9. }
  10.  
  11. proc nntp_kmsg {} {
  12.     global Config
  13.  
  14.     mprompt_clear
  15. }
  16.     
  17. #
  18. #  Posting PoPup
  19. #
  20. # Pass values in global variables because they may have arbitrary
  21. # characters in them
  22. #
  23. proc post_Make {already increment imessage args} {
  24.     global Config has_exmh
  25.     toplevel .post
  26.     frame .post.s
  27.     pack .post.s
  28.  
  29.     set n 0
  30.     foreach x $args {
  31.     global post_$x
  32.     frame .post.s.f$n
  33.     label .post.s.f$n.l -text $x
  34.     pack .post.s.f$n.l -side left -expand yes -fill x
  35.     entry .post.s.f$n.e  -width 60
  36.     .post.s.f$n.e delete 0 999
  37.     .post.s.f$n.e insert 0 [set post_$x]
  38.     pack   .post.s.f$n.e -side right
  39.     pack .post.s.f$n -fill x
  40.     incr n
  41.     }
  42.  
  43.     if {$increment == "1"} {
  44.     frame .post.i -borderwidth 2  -relief ridge
  45.     checkbutton .post.i.b -variable post_include -text $imessage -relief flat
  46.     global post_include
  47.     set post_include 1
  48.     pack .post.i.b
  49.     pack .post.i -expand yes -fill x
  50.     }
  51.  
  52.     frame .post.x -relief sunken -borderwidth 2
  53.     if {$already != -1} {
  54.     if {$already == 1} {
  55.         set xedit x
  56.     } else {
  57.         set xedit s
  58.     }
  59.     button .post.x.go -text "  Do  " -command "post_do $xedit $n"
  60.     button .post.x.exit  -text "Cancel" -command "post_exit"
  61.     pack .post.x.go  .post.x.exit -side left -padx 25m -pady 5m
  62.     } else {
  63.     if {$has_exmh} {
  64.         button .post.x.edit -text "internal editor" -command "post_do  s $n"
  65.     } else {
  66.         button .post.x.edit -text "internal editor" -command "post_do  s $n" -state disabled
  67.     }
  68.     button .post.x.xt -text "external editor" -command "post_do x $n" 
  69.     button .post.x.exit  -text "Cancel" -command "post_exit"
  70.  
  71.     pack .post.x.edit .post.x.xt .post.x.exit -side left -padx 12m -pady 5m
  72.     }
  73.     pack .post.x -side top -fill both -expand yes
  74.  
  75.     if {[info exists Config(.post)]} {
  76.     wm geometry  .post $Config(.post)
  77.     }
  78.     wm minsize .post 0 0
  79. }
  80.  
  81. proc post_do {c n} {
  82.  
  83.     if {$n > 0} {
  84.     for {set i 0} {$i < $n} {incr i} {
  85.         set var [lindex [.post.s.f$i.l configure -text] 4]
  86.         global post_$var
  87.         set post_$var  [.post.s.f$i.e get]
  88.     }
  89.     }
  90.  
  91.     if {![info exists post_Subject] || $post_Subject != ""} {
  92.     put_key $c
  93.     destroy .post
  94.     } else {
  95.     msg_tmp "You must enter a subject"
  96.     }
  97. }
  98.  
  99. proc post_exit {} {
  100.     put_key  e
  101.     destroy .post
  102. }
  103.  
  104. #
  105. # message - popup
  106. #
  107. proc msg_Make {mess warn} {
  108.     global Config
  109.  
  110.     if {$Config(compressed_prompt) != 0} {
  111.     mprompt_msg $mess
  112.     }
  113.  
  114.     if {($Config(compressed_prompt) != 2) || $warn} {
  115.     catch {destroy .msg}
  116.     toplevel .msg
  117.     wm transient .msg .
  118.     wm geometry .msg +300+300
  119.  
  120.     message .msg.m -text $mess -aspect 800
  121.  
  122.     pack .msg.m -side left -expand yes -fill both
  123.     }    
  124. }
  125.  
  126. proc msg_destroy {} {
  127.     global Config
  128.  
  129.     if {$Config(compressed_prompt) != 0} {
  130.     mprompt_clear
  131.     }
  132.     catch {destroy .msg}
  133. }
  134.  
  135. proc msg_tmp {mess} {
  136.     global Config
  137.  
  138.     msg_Make $mess 0
  139.     if {$Config(compressed_prompt) != 2} {
  140.     after 5000 {msg_destroy}
  141.     }
  142. }
  143.  
  144. proc msg_warn {mess} {
  145.     global Config
  146.  
  147.     msg_Make $mess 1
  148.     if {$Config(compressed_prompt) != 2} {
  149.     after 5000 {msg_destroy}
  150.     }
  151. }
  152.  
  153. #
  154. #    Group cascading menus
  155. #        pass group selection to nn
  156. proc gg {grp {menu ""}} {
  157.     global grp_x grp_y
  158.     global gm_type ev_param ev_type ev_input 
  159.     global EV_FUNCT token
  160.  
  161.     if {$menu != ""} {
  162.     update
  163. #    puts [winfo rootx .top.m.menu.$menu]
  164. #    puts [winfo rooty .top.m.menu.$menu]
  165. #    puts [winfo geometry  .top.m.menu.$menu]
  166.     scan  "[winfo geometry  .top.m.menu.$menu]" "%dx%d+%d+%d" sx sy x y
  167.     set ya [.top.m.menu.$menu yposition active]
  168.     } else {
  169.     scan  "[winfo geometry  .top.m.menu]" "%dx%d+%d+%d" sx sy x y
  170.     set ya [.top.m.menu yposition active]
  171.     }
  172.  
  173.     set grp_x [expr $sx/2+$x]
  174.     set grp_y [expr $y+$ya-6]
  175.     set gm_type "m"
  176.     set ev_param $grp
  177.     ev_type_menu
  178.     rec_c $EV_FUNCT $token(K_SEL_GROUP)
  179. }
  180.  
  181. #        display group jump menu
  182. proc gr_Make {} {
  183.     global grp_x grp_y
  184.     global list_cnt first_menu
  185.  
  186.     incr list_cnt
  187.  
  188.     if {[winfo exists .gr-popup]} {
  189.     destroy .gr-popup
  190.     }
  191.     menu .gr-popup
  192.     .gr-popup add command -label "Enter Group"
  193.     .gr-popup add separator
  194.     foreach i {"j)jump" "J)Jump read" "a)all"  "s)subject" "n)name" "e)either" \
  195.            "u)unread" "@)archive"} {
  196.     set a [string index $i 0]
  197.     set i [string range $i 2 end]
  198.     .gr-popup add command -label $i -accelerator $a -command "gr_select $a"
  199.     }
  200.  
  201.     if {![info exists grp_x]} {
  202.     if {[info exists .menu]} {
  203.         set grp_x [winfo rootx .menu]
  204.         set grp_y [winfo rooty .menu]
  205.     }
  206.     }
  207.     if {[info exists grp_x]} {
  208.     .gr-popup configure -tearoff no
  209.     tk_popup .gr-popup $grp_x [expr $grp_y-35]
  210.     grab release .gr-popup
  211.     if {![info exists first_menu]} {
  212. #        tkMenuBind .gr-popup Enter
  213.         set first_menu 1
  214.     }
  215.     
  216.     unset grp_x grp_y
  217.     update
  218.     }
  219. }
  220.  
  221. #        group jump menu selection
  222. proc gr_select {x} {
  223.     global ev_input  ev_type EV_CHAR 
  224.     global list_cnt      
  225.  
  226.     rec_c $EV_CHAR $x
  227.     .gr-popup unpost
  228.     destroy .gr-popup
  229.     set list_cnt 0
  230. }
  231.  
  232. proc gr_del {} {
  233.     global list_cnt      
  234.     #   fudgy variable to make sure window
  235.     #   isn't destroyed if it has to be reposted
  236.  
  237.     if {$list_cnt <= 1} {
  238.     if {[winfo exists .gr-popup]} {
  239.         destroy  .gr-popup
  240.     }
  241.     }
  242.     incr list_cnt -1
  243. }
  244.  
  245. #
  246. #    Group List
  247. #
  248. proc list_group {grp yc} {
  249.     set t [$grp get $yc.0 $yc.9999]
  250.     set l [expr [string first "\t" $t]-1]
  251.     if { $l > 0 } {
  252.     set t [string range $t 0 $l]
  253.     }
  254.     return $t
  255. }
  256.  
  257. #        pass group list selection to nn
  258. proc list_select {grp y} {
  259.     global gm_type ev_param ev_input ev_type 
  260.     global EV_FUNCT token
  261.  
  262.     set gm_type 'g'
  263.  
  264.     list_mark $grp $y
  265.  
  266.     set t [list_group $grp.list $y]
  267. #       puts stderr "$grp<$y>$t-"
  268.     set ev_param $t
  269.     if {$grp == ".folders"} {
  270.     set ev_param "+$ev_param"
  271.     }
  272.     ev_type_menu
  273.     rec_c $EV_FUNCT $token(K_SEL_GROUP)
  274. }
  275.  
  276. #        replace a group list entry
  277. proc list_update {ent y} {
  278. #    puts "list_update $ent $y"
  279.     if {$y >= 0} {
  280.     set nm [.groups.list tag names $y.0]
  281.     .groups.list delete $y.0 $y.9999
  282.     .groups.list insert $y.0 $ent $nm
  283.     }
  284. }
  285.  
  286. proc list_add {ent y} {
  287. #     puts "list_add $ent $y"
  288.     .groups.list insert end "$ent\n"
  289. }
  290.  
  291. proc list_flag {type rc {y 0} } {
  292.     global newsrc_sequence
  293.  
  294. #    puts "list_flag $type $rc $y"
  295.  
  296.     if {$y >=  0} {
  297.     if {$y == 0} {
  298.         scan [.groups.list index end] %d.%d y x
  299.         set y [expr $y-2]
  300.     }
  301.  
  302.     if {$type == "n"} {
  303.         .groups.list insert $y.9999 "\t "
  304.         .groups.list insert $y.9999 N lred
  305.     } elseif {$type == "u"} {
  306.         .groups.list insert $y.9999 "\t "
  307.         .groups.list insert $y.9999 U lblue
  308.     } elseif {$rc > 0  }  {
  309.         .groups.list insert $y.9999 "\t "
  310.     }    
  311.     if {$rc > 0  && $newsrc_sequence == 1}  {
  312.         .groups.list insert $y.9999 "\|" lgreen
  313.     }
  314.     }
  315. }
  316.  
  317. proc list_flag_raise {} {
  318.     .groups.list tag raise lred
  319.     .groups.list tag raise lblue
  320.     .groups.list tag raise lgreen
  321. }
  322.  
  323. proc group_save {n} {
  324.     global gpos_save
  325.     set gpos_save $n
  326. }
  327.  
  328. proc group_ret {t} {
  329.     global gpos_save
  330.     if {$t == "r"} {
  331.     list_mark .groups $gpos_save
  332.     }
  333. }
  334.  
  335. proc list_pos_save {} {
  336.     global list_pos_s
  337.     catch {
  338.     set n [.groups.list get sely.first sely.last]
  339.     scan $n "%s" list_pos_s
  340.     }
  341. }
  342.  
  343. proc list_pos_ret {} {
  344.     global list_pos_s
  345.     catch {list_mark .groups [lookup_group_pos $list_pos_s]}
  346. }
  347.  
  348. proc list_cl {} {
  349.     global Config
  350.  
  351.     .groups.list configure -width $Config(group_list_width)
  352.     list_tabs .groups.list
  353. }
  354.  
  355. proc list_clear {} {
  356.     if {[winfo exists .groups] != 0} {
  357.     list_pos_save
  358.     .groups.list delete 0.0 end
  359.     list_tabs .groups.list
  360.     grp_list
  361.     list_pos_ret
  362.     }
  363. }
  364.  
  365. proc list_reset {} {
  366.     if {[winfo exists .groups] != 0} {
  367.     list_pos_save
  368.     destroy .groups
  369.     list_Make .groups grp_list
  370.     thread_Make
  371.     list_pos_ret
  372.     }
  373. }
  374.  
  375. #        mark current group 
  376. proc list_mark {w y} {
  377.     global Config
  378.  
  379.     if {[winfo exists $w] != 0} {
  380.     if {$y > 0} {
  381.         $w.list tag remove sely 0.0 end
  382.         $w.list tag add sely $y.0 [expr $y+1].0
  383.         $w.list tag raise sely
  384.  
  385.         set t [$w.scroll get]
  386.         scan $t "%f %f" first last
  387.         set lines [$w.list index end]
  388.         set yl [expr $lines*$last]
  389.         set yf [expr $lines*$first]
  390. #        puts "lines=$lines first=$first last=$last yl=$yl yf=$yf y=$y"
  391.         if {($y > [expr $yl-$Config(group_list_page)]) || \
  392.             ($y < [expr $yf+$Config(group_list_page)])} {
  393.         $w.list yview [expr $y-4]
  394.         }
  395.     }
  396.     }
  397. }
  398.  
  399. #         create group list
  400. proc list_Make {grp flist} {
  401.     if {[winfo exists $grp] == 0} {
  402.     list_mk $grp
  403.     $flist
  404.     }
  405. }
  406.  
  407. proc group_handle_Make {w} {
  408.     global color_bd
  409.  
  410.     frame $w-handle -height 12 -width 12 -relief raised -borderwidth 2 \
  411.     -cursor sb_h_double_arrow -background $color_bd
  412.     place $w-handle -rely 0.05 -x -12 -in $w
  413.  
  414.     set xsize [lindex [.groups.thr.y configure -width] 4]
  415.     bind $w-handle <Button-1> "group_drag $w 0 $xsize"
  416.     bind $w-handle <B1-Motion> "group_drag $w %x $xsize"
  417.     bind $w-handle <ButtonRelease-1> "group_drag_resize $w %x $xsize"
  418.     frame $w-bar -width 3 -height 1800 -bg red
  419.     balloonHelp_traverse $w-handle
  420. }
  421.  
  422. proc group_drag {w x xsize} {
  423.     place $w-bar -y [top_y  $w 0] -x [expr [top_x  $w $x] - $xsize] -anchor n
  424. }
  425.     
  426. proc group_drag_resize {w x xsize} {
  427.  
  428.     if {$x < 0} {
  429.     set xsize [expr $xsize*2]
  430.     }
  431.     set curr [expr [top_x  $w $x] - $xsize]
  432.  
  433.     group_drag_resize_do $w $curr
  434.  
  435.     set nycurr [winfo height .groups.t]
  436.     pack propagate .groups.t 0
  437.     .groups.t configure -width $curr -height $nycurr
  438.  
  439.     list_tabs .groups.list
  440.     place  forget $w-bar
  441. }
  442.  
  443. proc group_drag_resize_do {w curr} {
  444.     global Config
  445.  
  446.     pack propagate .groups.t false
  447.     pack propagate .groups.t true
  448.     set menu_top [top_x .groups.list 0]
  449.     set menu_height [winfo width .groups.list]
  450.     set menu_chars [lindex [.groups.list configure -width] 4]
  451.     set new_size [expr (($curr-$menu_top)*$menu_chars)/$menu_height]
  452.     .groups.list configure -width $new_size
  453.     set Config(group_list_width) $new_size
  454. }
  455.  
  456. proc group_color {pat col} {
  457.     global color_list
  458.  
  459.     set start 0.0
  460.     .groups.list  tag configure b$col -background  $col -foreground black
  461.     lappend color_list b$col
  462.     while {[set fnd [.groups.list search $pat $start end]]  != "" } {
  463.     scan $fnd %d yc
  464.     .groups.list tag add b$col $yc.0 [expr $yc+1].0
  465.     set start [expr $yc+1].0
  466.     }
  467.     update
  468. }
  469.     
  470. proc group_color_clear {} {
  471.      global color_list
  472.  
  473.     foreach c $color_list {
  474.     .groups.list  tag remove $c 0.0 end
  475.     }
  476. }
  477.  
  478. proc group-search {grp up} {
  479.     global grp_x grp_y
  480.  
  481.     set srch [$grp.search.txt get]
  482.     if {$srch == ""} {
  483.     return
  484.     }
  485.  
  486.     if {$up} {
  487.     set start 999999.1
  488.     scan [$grp.list tag ranges sely] "%s" start
  489.     set fnd [$grp.list  search -backwards  $srch $start 0.0]
  490.     } else {
  491.     set start 0.1
  492.     scan [$grp.list tag ranges sely] "%s %s" d start
  493.     set fnd [$grp.list search  $srch $start end]
  494.     } 
  495.  
  496.     if {$fnd != ""} {
  497.     scan $fnd %d i
  498.     list_select $grp $i
  499.     list_mark $grp $i
  500.     set grp_x [expr [winfo rootx $grp.search.bt]+15]
  501.     set grp_y [winfo rooty $grp.search.bt] 
  502.     return
  503.     }
  504.  
  505.     msg_tmp "Group no found"
  506. }
  507.  
  508. proc group-srch {grp} {
  509.     frame $grp.search
  510.  
  511.     button $grp.search.bt -image down -command "group-search $grp 0" -bd 2 \
  512.     -relief raised
  513.     button  $grp.search.bf -image up  -command "group-search $grp 1"\
  514.     -bd 2 -relief raised
  515.     entry $grp.search.txt -relief sunken 
  516.     pack $grp.search.bt $grp.search.txt $grp.search.bf -side left  -pady 2 
  517.  
  518.     bind $grp.search.txt <Return> "group-search $grp 0; break"
  519. }
  520.  
  521.  
  522. proc list_press {grp window x y} {
  523.     global grp_x grp_y
  524.  
  525.     scan [$window index @$x,$y] %d.%d yc xc
  526.     set i [$window index @$x,$y]
  527. #puts "x=$x y=$y i=$i xc=$xc yc=$yc"
  528.     list_select $grp $yc
  529.     set x [expr [winfo rootx $window]+$x]
  530.     set y [expr [winfo rooty $window]+$y]
  531.     set grp_x $x
  532.     set grp_y $y 
  533. }
  534.  
  535. proc list_tabs {w} {
  536.     global  Config
  537.  
  538. #   need to substantiate the window to get the right size
  539.     update
  540.     set t2 [winfo width $w]
  541.  
  542.     if {$Config(group_list_all)} {
  543.     $w configure -tabs "[expr $t2-60] right [expr $t2-23]  right [expr $t2-10] right $t2 right"
  544.     } else {
  545.     $w configure -tabs "[expr $t2-30] right [expr $t2-8]  right $t2 right"
  546.     }
  547. }
  548.  
  549. proc list_mk {grp} {
  550.     global color_w color_bs Config nn_x_dir drag_id newsrc_sequence
  551.  
  552.     set newsrc_sequence [nn_get_var newsrc-sequence]
  553.  
  554.     set drag_id 0
  555.     if {$grp == ".groups"} {
  556.     if {$Config(single_main)} {
  557.         .top.f.func.w entryconfigure 1 -state disabled
  558.         frame  $grp -relief ridge -borderwidth 2
  559.     } else {
  560.         .top.f.func.w entryconfigure 1 -state normal
  561.         toplevel $grp
  562.         if {[info exists Config(.groups)]} {
  563.         set geom $Config(.groups)
  564.         }
  565.     }
  566.     } else {
  567.     toplevel $grp
  568.     if {[info exists Config(.folders)]} {
  569.         set geom $Config(.folders)
  570.     }
  571.     }
  572.  
  573.     frame $grp.t
  574.     frame $grp.t.b -borderwidth 2  -relief ridge
  575.     group-srch $grp
  576.     if {$grp ==  ".groups"} {
  577.     checkbutton $grp.mod -text Modify -command {modify_Make} \
  578.         -relief raised -bd 2 -variable groups_mod
  579.     pack $grp.mod -in $grp.t.b -side left -padx 5
  580.     }
  581.     pack $grp.search -in $grp.t.b
  582.     pack $grp.t -side top -fill both
  583.  
  584.     if {!$Config(single_main) || $grp !=  ".groups"} {
  585.     button $grp.t.dis  -text "Dismiss" -command "destroy $grp"
  586.     pack  $grp.t.dis -side right 
  587.     }
  588.     button $grp.t.help  -text "Help" -command "put_extended {help nn-tk-groups}"
  589.     pack  $grp.t.help -side right 
  590.     pack $grp.t.b -side left -expand y
  591.  
  592.     scrollbar $grp.scroll -command "$grp.list yview"
  593.     text $grp.list -yscroll "$grp.scroll set"  -relief raised -borderwidth 0 \
  594.     -cursor left_ptr -wrap none -spacing1 3
  595.     text_bindings $grp.list
  596.  
  597.     $grp.list  tag configure sely  -background  $color_bs -relief raised -borderwidth 1 
  598.     $grp.list  tag configure lred -foreground  red 
  599.     $grp.list  tag configure lblue -foreground  blue 
  600.     $grp.list  tag configure lgreen -foreground  green
  601.  
  602.     bind $grp.list <B1-Motion> {break}
  603.     bind $grp.list <Button-1> "list_press $grp %W %x %y"
  604.     bind $grp.list <ButtonRelease-1> {after cancel $drag_id}
  605.  
  606.     pack $grp.scroll -side right -fill y
  607.     pack $grp.list -side left -expand yes -fill both
  608.  
  609.     $grp.list configure -width $Config(group_list_width)
  610.     if {!$Config(single_main) || $grp !=  ".groups"} {
  611.     $grp.list configure -exportselection 0 -setgrid 1 
  612.     if {[info exists geom]} {
  613.         wm geometry $grp $geom
  614.     }
  615.     update
  616.     list_tabs $grp.list
  617.     } else {
  618.     $grp.list configure -exportselection 0 -setgrid 0 
  619.     pack $grp  -fill y -side left -padx 4 -before .top
  620.     }
  621.     balloonHelp_traverse $grp
  622. }
  623.  
  624. #
  625. #       Yes/No popup
  626. #
  627. proc y_prompt {} {
  628.     global prompt_buf
  629.     toplevel .yp 
  630.     regsub -all "\\1" $prompt_buf "" prompt_buf
  631.     regsub -all \x0d $prompt_buf "" prompt_buf
  632.     regsub -all \x01 $prompt_buf "" prompt_buf
  633.     wm transient .yp .
  634.     wm geometry .yp +300+300
  635.     message .yp.t -text $prompt_buf -aspect 1500
  636.     frame .yp.f -relief sunken -borderwidth 2
  637.     button .yp.f.yes -text "YES" -command "prompt_r y"
  638.     button .yp.f.no -text "NO" -command "prompt_r n"
  639.  
  640.     pack .yp.f.no -side left -padx 10m -pady 5m 
  641.     pack .yp.f.yes -side right -padx 10m -pady 5m
  642.     pack .yp.t -side top -expand yes -fill x
  643.     pack .yp.f -side top -fill both
  644.  
  645.     grab set .yp
  646.     focus .yp
  647.     bind .yp y {prompt_r y}
  648.     bind .yp Y {prompt_r y}
  649.     bind .yp n {prompt_r n}
  650.     bind .yp N {prompt_r n}
  651.     bind .yp escape {prompt_r n}
  652.     bind .yp <Key-Return> {prompt_r y}
  653. }
  654.  
  655. proc y_destroy {} {
  656.     if {[winfo exists .yp]} {
  657.     destroy .yp
  658.     }
  659. }
  660.  
  661. proc prompt_r {c} {
  662.     destroy .yp
  663.     put_key $c
  664. }
  665.  
  666. #
  667. #    Prompting popup
  668. #
  669. proc prompt_Make {} {
  670.     global color_w Config
  671.  
  672.     if {($Config(separate_prompt) == 1) && ($Config(compressed_prompt) != 2)} {
  673.     toplevel .prompt
  674.  
  675.     wm transient .prompt .
  676.     wm title .prompt "NN Prompt"
  677.     } else {
  678.     frame .prompt
  679.     }
  680.     
  681.     text .prompt.pr1 -relief raised -bd 2 \
  682.     -height 1
  683.     text .prompt.pr2 -relief raised -bd 2 \
  684.     -height 1
  685.     text .prompt.pr3 -relief raised -bd 2 \
  686.     -height 1
  687.  
  688.     if {($Config(separate_prompt) == 1) && ($Config(compressed_prompt) != 2)} {
  689.     .prompt.pr1 configure -setgrid true
  690.     .prompt.pr2  configure -setgrid true
  691.     .prompt.pr3  configure -setgrid true
  692.     }
  693.     if {$Config(compressed_prompt) != 2} {
  694.     pack .prompt.pr1 .prompt.pr2 .prompt.pr3 -side top \
  695.         -fill both -expand yes
  696.     }
  697.  
  698.     bind .prompt.pr1 <ButtonRelease-2> break
  699.     bind .prompt.pr2 <ButtonRelease-2> break
  700.     bind .prompt.pr3 <ButtonRelease-2> break
  701.  
  702.     bind .prompt <Destroy> prompt_d
  703.     bind .prompt.pr1 <2> prompt_insert
  704.     text_bindings .prompt.pr1
  705.     bind .prompt.pr2 <2> prompt_insert
  706.     text_bindings .prompt.pr2
  707.     bind .prompt.pr3 <2> prompt_insert
  708.     text_bindings .prompt.pr3
  709.  
  710.  
  711.     if {($Config(separate_prompt) == 1) && ($Config(compressed_prompt) != 2)} {
  712.     if {[info exists Config(.prompt)]} {
  713.         wm geometry  .prompt $Config(.prompt)
  714.     }
  715.     } 
  716. }
  717.  
  718. proc prompt_insert {} {
  719.     catch {set t [selection get]}
  720.     set n [string length $t]
  721.     for {set i 0} {$i < $n} {incr i} {
  722.     put_key [string index $t $i]
  723.     }
  724. }
  725.  
  726. proc prompt_clear {} {
  727.     global Config
  728.  
  729.     catch {
  730.     pprompt_clear 
  731.     .prompt.pr1 delete 0.0 end
  732.     .prompt.pr2 delete 0.0 end
  733.     .prompt.pr3 delete 0.0 end
  734.     if {($Config(separate_prompt) == 1) && ($Config(compressed_prompt) != 2)} {
  735.         wm withdraw .prompt
  736.         pack forget .prompt
  737.     }
  738.     }
  739. }
  740.  
  741. proc prompt_clrline {w pos} {
  742.  
  743.     $w delete $pos end
  744.     if {$w != ".menu-pr"} {
  745.     pprompt_clrline $pos
  746.     }
  747. }
  748.  
  749. proc prompt_restore {} {
  750.     global Config
  751.  
  752.     if {($Config(separate_prompt) == 1) && ($Config(compressed_prompt) != 2)} {
  753.     if {[winfo exists .prompt] == 0} {
  754.         prompt_Make
  755.     } else {
  756.         if {[winfo toplevel .prompt] == ".prompt"} {
  757.         wm deiconify .prompt
  758.         catch {
  759.             pack configure .prompt -after .more -side top -fill x
  760.         }
  761.         }
  762.     }
  763.     }
  764. }
  765.  
  766. proc prompt_d {} {
  767.     prompt_delete
  768. #
  769. #    display popup
  770. #
  771. proc display_l {} {
  772.     global display_l_t
  773.  
  774.     if {[winfo exists .display] == 0} {
  775.     display_Make
  776.     }
  777.  
  778.     set x $display_l_t
  779.     scan [.display.t index end] "%d." l
  780.     incr l -1
  781.  
  782.     set offset 0
  783.  
  784.     while {[regexp -indices "\01(\[^\01\]+)\01" $x pos]} {
  785.     scan $pos "%d %d" s f
  786.     set xt [string range $x 0 $f]
  787.     regsub -all \x01 $xt "" xt
  788.     .display.t insert end $xt
  789.     .display.t tag add out $l.[expr $offset+$s] $l.[expr $offset+$f-1]
  790.     set x [string range $x [expr $f+1] 999]
  791.     incr offset [expr $f-1]
  792.     }
  793.     regsub -all \x01 $x "" x
  794.  
  795.     .display.t insert end $x
  796. }
  797.  
  798. proc display_Make {} {
  799.     global color_w Config
  800.  
  801.     if {[winfo exists .display] == 0} {
  802.     toplevel .display
  803.  
  804.     frame .display.b 
  805.     button .display.b.b  -text "Dismiss" -command "destroy .display"
  806.     pack  .display.b.b -side right 
  807.     pack .display.b -side top -fill x
  808.  
  809.     text .display.t -relief raised -bd 2 -setgrid true \
  810.         -height 25 -width 80  -yscrollcommand ".display.s set" \
  811.         -wrap none
  812.     scrollbar .display.s -command ".display.t yview"
  813.     pack .display.t -side left -expand yes -fill both
  814.     pack .display.s -side left -fill y
  815.         .display.t tag configure out -background black -foreground white
  816.     wm title .display "NN help"
  817.     if {[info exists Config(.display)]} {
  818.         wm geometry .display $Config(.display)
  819.     }
  820.     } else {
  821.     .display.t delete 0.0 end
  822.     }
  823. }
  824.  
  825. #
  826. # deal with draging selection
  827. #
  828. proc modify_drag {y } {
  829.     global mod_prev tkPriv drag_id
  830.  
  831.     set resced 1
  832.     if {$y >= [winfo height .groups.list]} {
  833.     .groups.list yview scroll 2 units
  834.     } elseif {$y < 0} {
  835.     .groups.list yview scroll -2 units
  836.     } else {
  837.     set resced 0
  838.     }
  839.  
  840.     scan [.groups.list index @0,$y] %d yc
  841.     if {$yc != $mod_prev} {
  842.     if {$yc > $mod_prev} {
  843.         set n 1
  844.     } else {
  845.         set n -1
  846.     }
  847.     set ychk [expr $yc+$n]
  848.     for {set i [expr $mod_prev+$n]} {$i != $ychk} {incr i $n} {
  849.         modify_toggle_select $i
  850.     }
  851.     set mod_prev $yc
  852.     }
  853.  
  854.     after cancel $drag_id
  855.     if {$resced} {
  856.     set drag_id [after 100 "modify_drag $y"]
  857.     }    
  858. }
  859.  
  860. proc modify_toggle_select {i} {
  861.     if {[lsearch -exact [.groups.list tag name $i.0] sely] < 0} {
  862.     .groups.list tag add sely $i.0 [expr $i+1].0
  863.     } else {
  864.     .groups.list tag remove sely $i.0 [expr $i+1].0
  865.     }
  866. }
  867.  
  868. proc modify_clear {} {
  869.     .groups.list tag remove sely 0.0 end
  870. }
  871.               
  872. proc modify_all {} {
  873.     .groups.list tag add sely 0.0 end
  874. }
  875.               
  876. proc modify_sel {y} {
  877.     global mod_prev
  878.  
  879.     scan [.groups.list index @0,$y] %d yc
  880.     modify_toggle_select $yc
  881.     set mod_prev $yc
  882. }
  883.  
  884. proc modify_choose {cmd} {
  885.     set rg [.groups.list tag ranges sely]
  886. #    puts "=$rg"
  887.     set l [expr [llength $rg]/2]
  888.     for {set i 0} {$i < $l} {incr i} {
  889.     scan [lindex $rg [expr $i*2]] %d st
  890.     scan [lindex $rg [expr ($i*2)+1]] %d fn
  891. #    puts "-$st $fn"
  892.     for {set j $st} {$j < $fn} {incr j} {
  893.         scan [.groups.list get $j.0 $j.9999] %s grp
  894.         $cmd $grp
  895.     }
  896.     }
  897.     if {"$cmd" != "modify_sub"} {
  898.     end_subscribe
  899.     }
  900.     list_clear
  901. }
  902.  
  903. # select items in group list containing a string
  904. proc modify_select {} {
  905.     set srch [.modify.sl.s.e get]
  906.     if {$srch == ""} {
  907.     return
  908.     }
  909.     set start 0.0
  910.     while {[set fnd [.groups.list search $srch $start end]]  != "" } {
  911.     scan $fnd %d yc
  912.     .groups.list tag add sely $yc.0 [expr $yc+1].0
  913.     set start [expr $yc+1].0
  914.     }
  915. }
  916.     
  917. proc modify_sub {g} {
  918.     subscribe $g s
  919. }
  920.  
  921. proc modify_unsub {g} {
  922.     subscribe $g u
  923. }
  924.  
  925. proc modify_new {g} {
  926.     subscribe $g o
  927. }
  928.  
  929. # call C code for cutting part out of newsgroup sequence chain
  930. proc modify_cut {s f} {
  931.     scan $s %d st
  932.     scan $f %d fn
  933.     set snm [list_group .groups.list $st]
  934.     set fnm [list_group .groups.list $fn]
  935. #    puts "modify_cut $snm $fnm"
  936.     group_cut $snm $fnm
  937. }
  938.  
  939. proc modify_put_first {} {
  940.     modify_move 1
  941. }
  942.  
  943. proc modify_put_last {} {
  944.     scan [.groups.list index end] %d yc
  945.     modify_move [expr $yc-1]
  946. }
  947.    
  948. proc modify_put_after {} {
  949.     set srch [.modify.p.g.e get]
  950.     if {[set fnd [.groups.list search $srch 0.0 end]]  != ""} {
  951.     scan $fnd %d yc
  952.     modify_move $yc
  953.     } else {
  954.     msg_tmp "Not found"
  955.     }
  956. }
  957.     
  958. proc modify_paste {y} {
  959.     global tkPriv
  960.  
  961.     if {!$tkPriv(mouseMoved)} {
  962.     scan [.groups.list index @0,$y] %d yc
  963.     modify_move $yc
  964.     }
  965. }
  966.  
  967. proc modify_fix_sequence {} {
  968.     toplevel .mess
  969.     message .mess.m1 -text "Setting newsrc-sequence." -aspect 800
  970.     message .mess.m2 -text "Should the .newsrc file be used to determine the \
  971. entire newsgroup sequence or just the part matching RC in the init file sequence.\
  972. If you haven't set up a .nn/init file use Newsrc only." \
  973.     -aspect 500
  974.     pack .mess.m1 .mess.m2
  975.     frame .mess.f -relief ridge -borderwidth 2
  976.     button .mess.f.only -text "Newsrc only" -command "modify_fix_done 2"
  977.     button .mess.f.init -text "Init RC" -command "modify_fix_done 1"
  978.     pack .mess.f.only -side left -padx 10 -pady 5
  979.     pack .mess.f.init -side right -padx 10 -pady 5
  980.     pack .mess.f -expand yes -fill both
  981. }
  982.  
  983. proc modify_fix_done {flag} {
  984.     global variables_m variables_val
  985.  
  986.     set variables_m(newsrc-sequence) 1
  987.     set variables_val(newsrc-sequence) $flag
  988.     nn_set_var newsrc-sequence $flag
  989.  
  990.     variables_save
  991.     destroy .mess
  992. }
  993.  
  994. #
  995. # move groups in group list, at the same time
  996. # rearrange the newsgroup sequence chains in the
  997. # C code
  998. #
  999. proc modify_move {yc} {
  1000.     if {[nn_get_var newsrc-sequence] == 0} {
  1001.     modify_fix_sequence
  1002.     }
  1003.     set grp_paste [list_group .groups.list $yc]
  1004.     #      test if pasting at end
  1005.     if {$grp_paste == ""} {
  1006.     set grp_paste [list_group .groups.list [expr $yc-1]]
  1007.     set pos a
  1008.     } else {
  1009.     set pos b
  1010.     }
  1011.  
  1012.     .groups.list tag delete point
  1013.     .groups.list tag add point $yc.0 $yc.9999
  1014.  
  1015.     #    puts "$grp_paste $yc"
  1016.     set rg [.groups.list tag ranges sely]
  1017.     set l [expr ([llength $rg]/2)-1]
  1018.  
  1019.     #      check to make sure a range isn't being moved into itself
  1020.     for {set i $l} {$i >= 0} {incr i -1} {
  1021.     set s [lindex $rg [expr $i*2]] 
  1022.     set f [lindex $rg [expr ($i*2)+1]]
  1023.     if {($yc >= $s) && ($yc<$f)} {
  1024.         bell
  1025.         return 0
  1026.     }
  1027.     }
  1028.  
  1029.     text .groups.tmp
  1030.     #      process backwards so indexs don't change with deletions
  1031.     for {set i $l} {$i >= 0} {incr i -1} {
  1032.     set s [lindex $rg [expr $i*2]] 
  1033.     set f [lindex $rg [expr ($i*2)+1]]
  1034.  
  1035.     scan [.groups.list index end] "%d" fin
  1036.     if {$fin == $f} {
  1037.         set f [expr $f-1]
  1038.     }
  1039.     if {$f != $s} {
  1040.         modify_cut $s [expr $f-1]
  1041.         .groups.tmp insert 0.0 [.groups.list get $s $f]
  1042.         .groups.list delete $s $f
  1043.     }
  1044.     }
  1045.     
  1046.     group_paste $grp_paste $pos
  1047.     #    puts [lookup_group_pos $grp_paste].0
  1048.     scan [.groups.list tag  ranges point] %d yc
  1049.     .groups.list insert $yc.0 \
  1050.     [.groups.tmp get  0.0 "end - 1 chars"]
  1051.     destroy .groups.tmp
  1052. }
  1053.  
  1054. proc modify_Make {} {
  1055.     global Config groups_mod groups_pt
  1056.  
  1057.     if {$groups_mod} {
  1058.     toplevel .modify
  1059.  
  1060.     frame .modify.b
  1061. #    -borderwidth 2  -relief ridge
  1062.     button .modify.b.d -text "Dismiss" -command "modify_destroy"
  1063.     button .modify.b.h -text "Help" -command "put_extended {help nn-tk-modify}"
  1064.     pack .modify.b.d -side right
  1065.     pack .modify.b.h -side right
  1066.     pack .modify.b  -fill x
  1067.     
  1068.     label .modify.t -text "MODIFY GROUP LIST"
  1069.  
  1070.     frame .modify.sl -borderwidth 2  -relief ridge
  1071.     label .modify.sl.t -text "Manipulate slection"
  1072.     frame .modify.sl.s
  1073.     button .modify.sl.s.b -text "Select" -command "modify_select"
  1074.     entry .modify.sl.s.e
  1075.     button .modify.sl.sa -text "Select All" -command "modify_all"
  1076.     button .modify.sl.cl -text "Select None" -command "modify_clear"
  1077.     pack .modify.sl.s.b .modify.sl.s.e -side left
  1078.     pack  .modify.sl.t .modify.sl.sa .modify.sl.cl -fill x
  1079.  
  1080.     frame .modify.s -borderwidth 2  -relief ridge
  1081.     label .modify.s.t -text "Subscription"
  1082.     button .modify.s.sub -text "Subscribe" -command "modify_choose modify_sub"
  1083.     button .modify.s.unsub -text "unSubscribe" -command "modify_choose modify_unsub"
  1084.     button .modify.s.new -text "Clear new" -command "modify_choose modify_new"
  1085.     pack .modify.s.t .modify.s.sub .modify.s.unsub .modify.s.new  -fill x
  1086.  
  1087.     frame .modify.p -borderwidth 2  -relief ridge
  1088.     label .modify.p.t -text "Move Groups"
  1089.     button .modify.p.first -text "Put First" -command "modify_put_first"
  1090.     button .modify.p.last -text "Put Last" -command "modify_put_last"
  1091.     frame .modify.p.g
  1092.     button .modify.p.g.b -text "Put Before" -command "modify_put_after"
  1093.     entry .modify.p.g.e
  1094.     pack .modify.p.g.b .modify.p.g.e -side left -fill x
  1095.     pack .modify.p.t .modify.p.first .modify.p.last .modify.p.g -fill x
  1096.  
  1097.     pack .modify.t .modify.sl .modify.s .modify.p -fill x 
  1098.  
  1099.     balloonHelp_traverse .modify
  1100.     balloonHelp .groups.list "Select groups with the left mouse button, paste selected groups to a different position with the middle mouse button"
  1101.  
  1102.     bind .groups.list <Button-1> "modify_sel %y; break"
  1103.     bind .groups.list <B1-Motion> "modify_drag %y; break"
  1104.     bind .groups.list <ButtonRelease-2> "modify_paste %y; break"
  1105.     bind .groups.list <B1-Leave> "break"
  1106.     bind .groups.list <B1-Enter> "break"
  1107.     bind .modify <Destroy> modify_destroy
  1108.  
  1109.     list_pos_save
  1110.     .groups.list tag remove sely 0.0 end
  1111.     if {[info exists Config(.modify)]} {
  1112.         wm geometry  .modify $Config(.modify)
  1113.     }
  1114.     } else {
  1115.     modify_destroy
  1116.     }
  1117. }
  1118.  
  1119. proc modify_destroy {} {
  1120.     global groups_mod
  1121.  
  1122.     balloonHelp_traverse .groups.list
  1123.     .groups.list tag remove sely 0.0 end
  1124.     bind .groups.list <Button-1> "list_press .groups %W %x %y"
  1125.     bind .groups.list <B1-Motion> {break}
  1126.     catch {destroy .modify}
  1127.     list_pos_ret
  1128.     set groups_mod 0
  1129. }
  1130.  
  1131. #
  1132. # Thread structure display
  1133. #
  1134. proc thread_Make {} {
  1135.     global Config
  1136.     global areaX1 areaY1 areaX2 areaY2
  1137.  
  1138.     frame .groups.thr
  1139.     scrollbar .groups.thr.x -command ".groups.c xview" -width 7 -orient horiz 
  1140.     scrollbar .groups.thr.y -command ".groups.c yview" 
  1141.     canvas .groups.c -relief sunken -borderwidth 0 \
  1142.     -height $Config(thread_height) \
  1143.         -width 0 \
  1144.     -scrollregion {0 0 1500 1000} \
  1145.     -xscrollcommand ".groups.thr.x set" \
  1146.     -yscrollcommand ".groups.thr.y set"
  1147.     balloonHelp_traverse .groups.c
  1148.  
  1149.     if {$Config(thread_height) != 0} {
  1150.         pack .groups.thr.y -side right -fill y
  1151.         pack .groups.thr.x -side bottom -fill x
  1152.         pack .groups.c -side top  -fill both -in .groups.thr
  1153.         pack .groups.thr -side top  -fill both -before .groups.t
  1154.     }
  1155.  
  1156.     bind .groups.c <2> ".groups.c scan mark %x %y"
  1157.     bind .groups.c <B2-Motion> ".groups.c scan dragto %x %y"
  1158.     bind  .groups.c <1> "thread_draw_init %x %y 1"
  1159.     bind  .groups.c <B1-Motion> "thread_draw %x %y"
  1160.     bind  .groups.c <ButtonRelease-1> "thread_draw_in"
  1161.     bind  .groups.c <Button-3> "thread_draw_init %x %y 0"
  1162.     bind  .groups.c <B3-Motion> "thread_draw %x %y"
  1163.     bind  .groups.c <ButtonRelease-3> "thread_draw_in"
  1164. }
  1165.  
  1166. proc thread_nmark {x y} {
  1167.     global nid bid nprev bprev Config
  1168.  
  1169.     if {$Config(thread_height) != 0 && [info exists nid($x,$y)]} {
  1170.         # mark current node
  1171.         .groups.c itemconfigure $nid($x,$y) -fill white
  1172.         .groups.c itemconfigure $bid($x,$y) -fill red -outline red
  1173.         .groups.c lower $bid($x,$y)
  1174.  
  1175.         # unmark previous node
  1176.         if {[info exists nprev]} {
  1177.             .groups.c itemconfigure $nprev -fill black
  1178.             .groups.c itemconfigure $bprev -fill ""
  1179.         }
  1180.  
  1181.         # scroll so current node is visible
  1182.         scan [.groups.c bbox $nid($x,$y)] "%d %d %d %d" x1 y1 x2 y2
  1183.         scan [.groups.c cget -scrollregion] "%d %d %d %d" lx1 ly1 lx2 ly2
  1184.  
  1185.         #    puts [.groups.thr.y get]
  1186.  
  1187.         set xs [expr $x1*1.0/$lx2]
  1188.         set ys [expr $y1*1.0/$ly2]
  1189.         set xf [expr $x2*1.0/$lx2]
  1190.         set yf [expr $y2*1.0/$ly2]
  1191.  
  1192.         scan [.groups.thr.x get] "%f %f" xmin xmax
  1193.         scan [.groups.thr.y get] "%f %f" ymin ymax
  1194.  
  1195.         if {$xs < $xmin || $xf > $xmax} {
  1196.             .groups.c xview moveto [expr $xs-($xf-$xs)*3 ]
  1197.         } else {
  1198.             .groups.c xview moveto $xmin
  1199.         }
  1200.  
  1201.         if {$ys < $ymin || $yf > $ymax} {
  1202.             .groups.c yview moveto [expr $ys-($yf-$ys)*0.5 ]
  1203.         } else {
  1204.             .groups.c yview moveto $ymin
  1205.         }
  1206.  
  1207. # remember last node
  1208.         set nprev $nid($x,$y)
  1209.         set bprev $bid($x,$y)
  1210.     }
  1211. }
  1212.  
  1213. proc thread_button {box_id} {
  1214.     global token th_num
  1215.     
  1216.     set a_num $th_num($box_id)
  1217.  
  1218.     set w  [lindex [.groups.c itemconfigure $box_id -width] 4]
  1219.     if {$w == 1} {
  1220.     .groups.c itemconfigure $box_id -width 2
  1221.     } else {
  1222.     .groups.c itemconfigure $box_id -width 1
  1223.     }
  1224.     toggle_select $a_num
  1225.     put_funct $token(K_READ_GROUP_UPDATE) "m"
  1226. }
  1227.  
  1228. proc thread_set {box_id on} {
  1229.     global th_num
  1230.  
  1231.     if {[info exists th_num($box_id)]} {
  1232.     incr on
  1233.     set w  [lindex [.groups.c itemconfigure $box_id -width] 4]
  1234.     if {$w != $on} {
  1235.         .groups.c itemconfigure $box_id -width $on
  1236.         toggle_select $th_num($box_id)
  1237.     }
  1238.     }
  1239. }
  1240.   
  1241. proc thread_node {x y selected a_num} {
  1242.     global thread_text nid bid th_num
  1243.  
  1244.     set t $thread_text
  1245.     set l [llength $t]
  1246.  
  1247.     if {$l > 1} {
  1248.     set c1 [string range [lindex $t 0] 0 0]
  1249.     set c2 " "
  1250.     set c2 [string range [lindex $t 1] 0 0]
  1251.     set c3 " "
  1252.     if {[llength $t] > 2} {
  1253.         set c3 [string range [lindex $t [expr [llength $t]-1]] 0 0]
  1254.     }
  1255.     set node "$c1$c2$c3"
  1256.     } else {
  1257.     set node  [string range $t 0 2]
  1258.     }
  1259.     set n_id [.groups.c create text [expr 33*$x+30] [expr 22*$y+10] \
  1260.             -text $node -anchor ne -tags nodes \
  1261.             -font [option get .groups.c font {} ]]
  1262.     set nid($x,$y) $n_id
  1263.     set box [.groups.c bbox $n_id]
  1264.     set x1 [expr [lindex $box 0]-2]
  1265.     set y1 [expr [lindex $box 1]-2]
  1266.     set x2 [lindex $box 2]
  1267.     set y2 [lindex $box 3]
  1268.  
  1269.     set box_id [.groups.c create rectangle \
  1270.             $x1 $y1 $x2 $y2 -tags nodes ]
  1271.     set th_num($box_id) $a_num
  1272.     set bid($x,$y) $box_id
  1273.  
  1274. #   the width flags if selected or not
  1275.     if {$selected == 1} {
  1276.     .groups.c itemconfigure $box_id -width 2
  1277.     }
  1278.  
  1279.     if {$a_num >= 0} {
  1280.     .groups.c bind $n_id <Button-1>  "thread_button $box_id"
  1281.     }
  1282.  
  1283.     set xp [expr $x-1]
  1284.     set yp $y
  1285.     set ymid [expr ($y2+$y1)/2]
  1286.     if {[info exists bid($xp,$yp)]} {
  1287.     set pbox [.groups.c bbox $bid($xp,$yp)]
  1288.     .groups.c create line $x1  $ymid \
  1289.          [lindex $pbox 2] $ymid \
  1290.         -tags nodes
  1291.     } else {
  1292.     while {$yp > 0} {
  1293.         incr yp -1
  1294.         if {[info exists bid($xp,$yp)]} {
  1295.         set pbox [.groups.c bbox $bid($xp,$yp)]
  1296.         set xmid [expr ([lindex $pbox 0]+[lindex $pbox 2])/2]
  1297.         .groups.c create line $x1  $ymid \
  1298.             $xmid $ymid $xmid [lindex $pbox 3] \
  1299.             -tags nodes
  1300.         break
  1301.         }
  1302.     }
  1303.     }
  1304. }
  1305.  
  1306. proc thread_clear {} {
  1307.     global nid bid nprev 
  1308.  
  1309.     .groups.c  delete nodes
  1310.     .groups.c xview moveto 0
  1311.     .groups.c yview moveto 0
  1312.     catch {
  1313.     unset nid
  1314.     unset bid
  1315.     unset th_num
  1316.         unset nprev
  1317.         .groups.c delete area
  1318.     }
  1319. }
  1320.  
  1321. proc thread_draw_init {x y on} {
  1322.     global areaX1 areaY1  areaX2 areaY2 thread_on
  1323.     set thread_on $on
  1324.     set areaX1 [.groups.c canvasx $x]
  1325.     set areaY1 [.groups.c canvasy $y]
  1326.     set areaX2 $areaX1
  1327.     set areaY2 $areaY1
  1328.     .groups.c delete area
  1329. }
  1330.     
  1331. proc thread_draw {x y} {
  1332.     global areaX1 areaY1 areaX2 areaY2 thread_on
  1333.  
  1334.     if {$thread_on == 1} {
  1335.     set col "green"
  1336.     } else {
  1337.     set col "red"
  1338.     }
  1339.  
  1340.     set x [.groups.c canvasx $x]
  1341.     set y [.groups.c canvasy $y]
  1342.     if {($areaX1 != $x) && ($areaY1 != $y)} {
  1343.     .groups.c delete area
  1344.     .groups.c addtag area withtag [.groups.c create rect $areaX1 $areaY1 $x $y \
  1345.         -outline $col]
  1346.     set areaX2 $x
  1347.     set areaY2 $y
  1348.     }
  1349. }
  1350.  
  1351. proc thread_draw_in {} {
  1352.     global areaX1 areaY1 areaX2 areaY2 thread_on token
  1353.     set area [.groups.c find withtag area]
  1354.  
  1355.     foreach i [.groups.c find overlapping $areaX1 $areaY1 $areaX2 $areaY2] {
  1356.     if {[.groups.c type $i] == "rectangle"} {
  1357.         thread_set $i $thread_on
  1358.     }
  1359.     }
  1360.     .groups.c delete area
  1361.     put_funct $token(K_READ_GROUP_UPDATE) "m"
  1362. }
  1363.  
  1364. proc thread_handle_Make {w} {
  1365.     global color_bd
  1366.  
  1367.     frame $w-handle -height 12 -width 12 -relief raised -borderwidth 2 \
  1368.     -cursor double_arrow -background $color_bd
  1369.     place $w-handle -relx 0.85 -y -6 -in $w
  1370.  
  1371.     bind $w-handle <Button-1> "thread_drag $w 0"
  1372.     bind $w-handle <B1-Motion> "thread_drag $w %y"
  1373.     bind $w-handle <ButtonRelease-1> "thread_drag_resize $w %y"
  1374.     frame $w-bar -width 800 -height 3 -bg red
  1375.     balloonHelp_traverse $w-handle
  1376. }
  1377.  
  1378. proc thread_drag {w y} {
  1379.     place $w-bar -y [top_y  $w $y] -x [top_x  $w 0] -anchor w
  1380. }
  1381.     
  1382. proc thread_drag_resize {w y} {
  1383.     global Config
  1384.  
  1385.     set curr [top_y  $w $y]
  1386.     set menu_top [top_y .groups.c 0]
  1387.     set new_size [expr $curr-$menu_top-[winfo height .groups.thr.x]]
  1388.     .groups.c configure -height $new_size
  1389.     set Config(thread_height) $new_size
  1390.     place  forget $w-bar
  1391. }
  1392.